//适用于商品列表倒计时
/**
 * end_time int 结束时间
 * param int 数组键
 */
function grouponcountdown(that, end_time, param) {
  var EndTime = end_time || [];
  var NowTime = new Date().getTime();

  var total_micro_second = EndTime - NowTime || [];

  var groupons = that.data.groupon;
  groupons[param].endtime = dateformat(total_micro_second);
  if (total_micro_second <= 0) {
    groupons[param].endtime = "已经截止"
  }
  that.setData({
    groupon: groupons
  })

  setTimeout(function () {
    groupcount(that, end_time, param);
  }, 1000)
}
// 时间格式化输出，如11:03 25:19 每1s都会调用一次
function dateformat(micro_second, t = 0) {
  // 总秒数
  var second = Math.floor(micro_second / 1000);
  // 天数
  var day = Math.floor(second / 3600 / 24);
  // 小时
  var hr = Math.floor(second / 3600 % 24);
  // 分钟
  var min = Math.floor(second / 60 % 60);
  // 秒
  var sec = Math.floor(second % 60);
  if (t == 0) {
    return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
  } else {
    return hr + "小时" + min + "分钟" + sec + "秒";
  }
}